package cn.csc.module.member.dal.mysql.userrole;

import java.util.*;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.module.member.dal.dataobject.userrole.MemberUserRoleDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csc.module.member.controller.app.userrole.vo.*;

/**
 * 会员和角色关联 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface MemberUserRoleMapper extends BaseMapperX<MemberUserRoleDO> {

    default PageResult<MemberUserRoleDO> selectPage(AppMemberUserRolePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberUserRoleDO>()
                .eqIfPresent(MemberUserRoleDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberUserRoleDO::getRoleId, reqVO.getRoleId())
                .betweenIfPresent(MemberUserRoleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberUserRoleDO::getId));
    }

    default List<MemberUserRoleDO> selectList(AppMemberUserRoleExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MemberUserRoleDO>()
                .eqIfPresent(MemberUserRoleDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberUserRoleDO::getRoleId, reqVO.getRoleId())
                .betweenIfPresent(MemberUserRoleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberUserRoleDO::getId));
    }

}
